package com.fundamentalesandroid;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;


public class CustomAudioPlayer extends Activity implements OnCompletionListener {

	MediaPlayer mediaPlayer;
	
	@Override
	public void onCompletion(MediaPlayer arg0) {
		mediaPlayer.start();

	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}
	
	public void onStart(){
		super.onStart();
		mediaPlayer=MediaPlayer.create(this, R.raw.sound);
		mediaPlayer.setOnCompletionListener(this);
		mediaPlayer.start();		
	}

	public void onStop(){
		super.onStop();
		mediaPlayer.stop();
		mediaPlayer.release();
	}
	
}
